﻿using System;
using System.Text.RegularExpressions;

namespace WZ.Utils.WebHttp
{
    public class JsonContext
    {
        

        /// <summary>
        /// 将Json序列化的时间由/Date(1294499956278+0800)转为字符串
        /// </summary>
        private static string ConvertJsonDateToDateString(Match m)
        {
            string result = string.Empty;
            DateTime dt = new DateTime(1970, 1, 1);
            dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value));
            dt = dt.ToLocalTime();
            result = dt.ToString("yyyy-MM-dd HH:mm:ss");
            return result;
        }

        /// <summary>
        /// 将时间字符串转为Json时间
        /// </summary>
        private static string ConvertDateStringToJsonDate(Match m)
        {
            string result = string.Empty;
            DateTime dt = DateTime.Parse(m.Groups[0].Value);
            dt = dt.ToUniversalTime();
            TimeSpan ts = dt - DateTime.Parse("1970-01-01");
            result = string.Format("\\/Date({0}+0800)\\/", ts.TotalMilliseconds);
            return result;
        }

        public JsonContext()
        {
        }

        public JsonContext(String context)
        {
            Context = context;
        }

        /// <summary>
        /// json串正文
        /// </summary>
        public String Context { get; set; }

        /// <summary>
        /// 将Json正文转化成对象
        /// </summary>
        /// <typeparam name="T">待转换类型</typeparam>
        /// <returns></returns>
        
    }
}
